package com.alt.adapter;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;

import com.alt.R;
import com.alt.models.ImageModel;
import com.alt.ui.ALTViewImage;
import com.alt.utils.ALTSysUtils;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

public class ListImageAdapter extends PagerAdapter {
	private ALTViewImage activity;

	static class ViewHolder {
	}

	private ArrayList<String> listImage;
	private LayoutInflater inflater;
	private ImageView imgView;

	public ListImageAdapter(ArrayList<String> _listImage, ALTViewImage context) {
		listImage = _listImage;
		this.inflater = context.getLayoutInflater();
		activity = context;
	}

	@Override
	public void destroyItem(final View container, final int position, final Object object) {
		((ViewPager) container).removeView((View) object);

	}

	@Override
	public void finishUpdate(final View container) {
	}

	@Override
	public int getCount() {
		return this.listImage.size();
	}

	@Override
	public Object instantiateItem(final View view, final int position) {

		final View imageLayout = this.inflater.inflate(R.layout.item_image_menu_layout, null);
		imgView = (ImageView) imageLayout.findViewById(R.id.imgMenu);
		try {
//			activity.imageLoader.displayImage(activity, "http://digipay.vn:8080/CommonSvc/common/getfilestream/" + listImage.get(position), imgView, activity.options, true);
		} catch (Exception e) {
			Log.v("HAI", "no image");
		}

		((ViewPager) view).addView(imageLayout, 0);
		return imageLayout;
	}

	@Override
	public boolean isViewFromObject(final View view, final Object object) {
		return view.equals(object);
	}

	@Override
	public void restoreState(final Parcelable state, final ClassLoader loader) {
	}

	@Override
	public Parcelable saveState() {
		return null;
	}

	@Override
	public void startUpdate(final View container) {
	}

}
